package com.xz.xzutils.components.console;

import com.intellij.execution.filters.TextConsoleBuilder;
import com.intellij.execution.filters.TextConsoleBuilderFactory;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.openapi.project.Project;

import java.util.ArrayList;

/**
 * <p>
 *
 * </p>
 *
 * @author DONG.WANG17@HAND-CHINA.COM
 * @apiNote
 * @since 2025-01-14 17:25
 */
public class SqlConsoleCreator {
    private SqlConsoleCreator() {
    }

    public static SqlConsole createSqlConsole(Project project) {
        TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
        consoleBuilder.setViewer(true);
        // 去除 默认过滤器
        consoleBuilder.filters(new ArrayList<>());
        ConsoleView consoleView = consoleBuilder.getConsole();
        SqlConsole console = new SqlConsole(consoleView);
        console.addMessageFilter(new SqlConsoleFilter(project));
        // console.addMessageFilter(new UrlFilter());

        console.logInfoLn(".------..------..------..------..------..------..------.");
        console.logDebugLn("|X.--. ||Z.--. ||U.--. ||T.--. ||I.--. ||L.--. ||S.--. |");
        console.logWarnLn("| :/\\: || :(): || (\\/) || :/\\: || (\\/) || :/\\: || :/\\: |");
        console.logErrorLn("| (__) || ()() || :\\/: || (__) || :\\/: || (__) || :\\/: |");
        console.logVerboseLn("| '--'X|| '--'Z|| '--'U|| '--'T|| '--'I|| '--'L|| '--'S|");
        console.normalLn("`------'`------'`------'`------'`------'`------'`------'");
        console.userInputLn("----------------------------------------- XzUtils(1.0.0)");
        // console.userInputLn("---------------------------------- Xz: 1378511152@qq.com");
        return console;
    }
}
